package net.mgsx.product.t2m.modisco.tools;

import org.eclipse.gmt.modisco.java.ASTNode;
import org.eclipse.gmt.modisco.java.ClassInstanceCreation;
import org.eclipse.gmt.modisco.java.Comment;
import org.eclipse.gmt.modisco.java.Javadoc;
import org.eclipse.gmt.modisco.java.NamedElement;
import org.eclipse.gmt.modisco.java.ParameterizedType;
import org.eclipse.gmt.modisco.java.PrimitiveType;

/**
 * Utility class for quality queries
 * 
 * @author mgsx
 *
 */
public class QualityUtils {

	public static boolean isNotProxy(ASTNode context)
	{
		boolean result = true;
		if(context instanceof NamedElement && 
				((NamedElement)context).isProxy())
		{
			result = false;
		}
		else if(context instanceof ClassInstanceCreation)
		{
			
			result = isNotProxy(((ClassInstanceCreation) context).getType().getType());
		}
		else if(context instanceof ParameterizedType)
		{
			result = isNotProxy(((ParameterizedType) context).getType().getType());
		}
		return result;
	}
	
	public static boolean hasJavaDoc(ASTNode context)
	{
		for(Comment comment : context.getComments())
		{
			if(comment instanceof Javadoc)
			{
				return true;
			}
		}
		return false;
	}
	
}
